import random

import redis   # 导入redis 模块
from gevent import time
import sys



def main_process():
    print("调用方法："+sys._getframe().f_code.co_name)
    proxy = getproxy()
    print(proxy)
    a=1;
    # print(type(r.get('proxies')))  # 查看类型


def getproxy():
    r = redis.Redis(host='127.0.0.1', port=6379, decode_responses=True)
    proxies = eval(r.get('proxies'))
    index = random.randint(0, len(proxies) - 1)
    return proxies[index]


if __name__ == '__main__':
    main_process()

